<template>
    <div class="rights">
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <el-table :data="rightsList" border stripe>
                <el-table-column type="index" label="#"></el-table-column>
                <el-table-column  label="权限名称" prop="authName" align="center"></el-table-column>
                <el-table-column  label="路径" prop="path" align="center"></el-table-column>
                <el-table-column  label="权限等级" prop="level" align="center">
                    <template v-slot="slot">
                        <el-tag v-show="slot.row.level==='0'">一级</el-tag>
                        <el-tag type="success" v-show="slot.row.level==='1'">二级</el-tag>
                        <el-tag type="warning" v-show="slot.row.level==='2'">三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>

    </div>
</template>

<script>
    export default {
        name: "rights",
        data(){
            return{
                rightsList:[]
            }
        },
        created() {
            this.getRightsList();
        },
        methods:{
            async getRightsList(){
                const {data:res}=await this.$http.get("rights/list");
                if(res.meta.status!==200){
                    return this.$message.error("请求失败")
                }
                var data=res.data;
                var m=[];
                for(var j=0;j<3;j++){
                    for(var i=0;i<data.length;i++){
                        if(parseInt(data[i].level)===j){
                            m.push(data[i]);
                            m.splice(i,1);
                        }
                    }
                }
                this.rightsList=m;
                // this.rightsList=res.data;
                console.log(this.rightsList);
            }
        }

    }
</script>

<style lang="less" scoped>
    .rights{
        padding: 15px;
        .el-card{
            margin-top: 15px;
        }
    }


</style>
